<template>
  <div class="child1">
    <header class='clearFixed'>
      <i class="el-icon-news"></i>最新赛事
      <span class="fr">+更多</span>
      <ul class="nav">
        <li v-for='(item,index) in newsnav' :key='index' :class="{liactive:thisone==index}" @mouseenter="thisone=index" @mouseover="thislist">{{item}}</li>
      </ul>
    </header>
    <div class="newslist-con">
      <!-- 单独的新闻列表组件 -->
      <div class="news-con clearFixed" v-for="(item,index) in newsinfo" :key="item.iDocID" >
        <span class="fl tag">{{item.iSubType}}</span>
        <div class="newslist fs16 fl" @mouseenter="thisnews(index)" :class="{newslistactive:index==newsindex}">
          <div class="newslist_title">
            {{item.sTitle}}
          </div>
          <div class="newslist_con">
            <div class="news-detail">
              <div class="news-detail-pic fl w230">
                <img :src="item.sIMG" alt="">
              </div>
              <div class="news-detail-word fl w370 fs14">
                {{item.sDesc}}
              </div>
            </div>
          </div>
        </div>
        <div class="newsTime fr">12-22</div>
      </div>
      <!-- 单独的新闻列表组件 -->
    </div>
  </div>
</template>
<script>
export default {
  data: () => ({
    newsinfo: [],
    newsindex: 0,
    thisone: '0',
    newsnav: ['全部', 'KPL', 'KCC', 'KPKPL', '城市赛', '高校赛', 'TGA', 'WGI']
  }),
  created () {
    this.getNews()
  },
  methods: {
    async getNews () {
      const {
        data: { datas, froms, msg, status }
      } = await this.$axios.get('/match/newsdata')
      if (status !== 0) console.log(datas, froms)
      this.newsinfo = msg[this.thisone].result
    },
    thisnews (index) {
      this.newsindex = index
    },
    thislist () {
      this.getNews()
    }
  }
}
</script>
<style lang="less" scoped>
li{
  list-style: none;
}
.fs22{
  font-size: 22px;
}
.w230{
  width: 230px;
}
.w370{
  width: 370px;
}
.fs14{
  font-size: 14px;
}
.fl{
  float: left;
}
.fr{
  float: right;
}
.clearFixed:after{
  content:"";
  display:block;
  clear:both;
}
.child1{
  width: 820px;
  height: 500px;
  header{
    position: relative;
    height: 40px;
    font-size: 22px;
    border-bottom: 2px solid #ddd;
    margin-bottom: 20px;
    span{
      font-size: 16px;
      columns: #c0c0c0;
      line-height: 42px;
    }
    .nav{
      position: absolute;
      left: 90px;
      top: -20px;
      width: 500px;
      display: flex;
      justify-content: space-between;
      li{
        font-size: 16px;
        line-height: 38px;
      }
      .liactive{
        color: gold;
        border-bottom: 2px solid gold;
      }
    }
  }
  .news-con{
    .tag{
      display: block;
      width: 50px;
      border-radius: 5px;
      background-color: #ddd;
      font-size: 12px;
      text-align: center;
      line-height: 20px;
      margin-top: 10px;
    }
    .newslist{
      height: 30px;
      margin-left: 20px;
      overflow: hidden;
      transition: all .3s ease;
      .newslist_title{
        white-space:nowrap;
        overflow:hidden;
        text-overflow:ellipsis;
        width: 640px;
        line-height: 40px;
      }
      .newslist_con{
        font-weight: normal;
        .news-detail{
          .news-detail-pic{
            margin-right: 20px;
          }
          .news-detail-word{
            line-height: 25px;
          }
        }
      }
    }
    .newslistactive{
      font-size: 22px;
      height: 176px;
      font-weight: bold;
    }
    .newsTime{
      color: #999;
      font-size: 16px;
      display: block;
      margin-right: 30px;
    }
  }
}
</style>
